Skip to content

Commit

Permalink
Bump moesifapi version to 1.2.6
Browse files Browse the repository at this point in the history
Bump moesifapi version to 1.2.6
Refactor: UpdateUser tests
Refactor: Update README.md
Bump version to 1.6.2
  • Loading branch information
Keyur committed Aug 26, 2019
1 parent af66293 commit 0642144
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ A more detailed example is available at [https://github.com/Moesif/moesifdjangoe
def identifyUser(req, res):
# if your setup do not use the standard request.user.username
# return the user id here
return "user_id_1"
return "my_user_id"

def identifyCompany(req, res):
# return the company id here
return "12345"
return "my_company_id"

def should_skip(req, res):
if "healthprobe" in req.path:
Expand Down Expand Up @@ -245,7 +245,8 @@ The metadata field can be any custom data you want to set on the user. The `user
```python
middleware = MoesifMiddleware(None)
update_user = middleware.update_user({
'user_id': 'testpythonapiuser',
'user_id': '12345',
'company_id': '67890',
'session_token': 'jkj9324-23489y5324-ksndf8-d9syf8',
'metadata': {'email': 'abc@email.com', 'name': 'abcde', 'image': '1234'}
})
Expand All @@ -258,10 +259,12 @@ The metadata field can be any custom data you want to set on the user. The `user
```python
middleware = MoesifMiddleware(None)
update_users = middleware.update_users_batch([{
'user_id': 'testpythonapiuser',
'user_id': '12345',
'company_id': '67890',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}, {
'user_id': 'testpythonapiuser1',
'user_id': '1234',
'company_id': '6789',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}])
```
Expand All @@ -275,7 +278,7 @@ The metadata field can be any custom data you want to set on the company. The `c
```python
middleware = MoesifMiddleware(None)
update_company = middleware.update_company({
'company_id': '1',
'company_id': '12345',
'company_domain': 'acmeinc.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcde', 'image': '1234'}
})
Expand All @@ -288,11 +291,11 @@ The metadata field can be any custom data you want to set on the company. The `c
```python
middleware = MoesifMiddleware(None)
update_companies = middleware.update_companies_batch([{
'company_id': '1',
'company_id': '12345',
'company_domain': 'nowhere.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}, {
'company_id': '2',
'company_id': '67890',
'company_domain': 'acmeinc.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}])
Expand Down Expand Up @@ -332,7 +335,7 @@ An example Moesif integration based on quick start tutorials of Django and Djang

## Other integrations

To view more more documentation on integration options, please visit __[the Integration Options Documentation](https://www.moesif.com/docs/getting-started/integration-options/).__
To view more documentation on integration options, please visit __[the Integration Options Documentation](https://www.moesif.com/docs/getting-started/integration-options/).__

[ico-built-for]: https://img.shields.io/badge/built%20for-django-blue.svg
[ico-version]: https://img.shields.io/pypi/v/moesifdjango.svg
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jsonpickle==0.7.1
python-dateutil==2.5.3
nose==1.3.7
isodatetimehandler==1.0.2
moesifapi==1.2.5
moesifapi==1.2.6
celery>=3.1.25
moesifpythonrequest==0.1.11
apscheduler==3.6.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='1.6.1',
version='1.6.2',

description='Moesif Middleware for Python Django',
long_description=long_description,
Expand Down
17 changes: 10 additions & 7 deletions tests/middleware_pre19_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MoesifMiddlewarePre19Test(TestCase):

def setUp(self):
self.request_factory = RequestFactory()
self.user = User.objects.create_user(username='testpythonapiuser', email='test@test.com', password='top_secret')
self.user = User.objects.create_user(username='my_user_id', email='test@test.com', password='top_secret')

def test_get_patched_middlesettings(self):
def get_response(req):
Expand All @@ -35,7 +35,8 @@ class UpdateUserTests(SimpleTestCase):

def testUpdateUser(self):
MoesifMiddlewarePre19().update_user({
'user_id': 'testpythonapiuser',
'user_id': '12345',
'company_id' : '67890',
'session_token': 'jkj9324-23489y5324-ksndf8-d9syf8',
'metadata': {'email': 'abc@email.com', 'name': 'abcde', 'image': '1234'}
})
Expand All @@ -44,18 +45,20 @@ class UpdateUsersBatchTest(SimpleTestCase):

def testUpdateUsersBatch(self):
MoesifMiddlewarePre19().update_users_batch([{
'user_id': 'testpythonapiuser',
'user_id': '12345',
'company_id' : '67890',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}, {
'user_id': 'testpythonapiuser1',
'user_id': '1234',
'company_id' : '6789',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}])

class UpdateCompanyTest(SimpleTestCase):

def testUpdateCompany(self):
MoesifMiddlewarePre19().update_company({
'company_id': '1',
'company_id': '12345',
'company_domain': 'acmeinc.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcde', 'image': '1234'}
})
Expand All @@ -64,11 +67,11 @@ class UpdateCompaniesBatchTest(SimpleTestCase):

def testUpdateCompaniesBatch(self):
MoesifMiddlewarePre19().update_companies_batch([{
'company_id': '1',
'company_id': '12345',
'company_domain': 'nowhere.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}, {
'company_id': '2',
'company_id': '67890',
'company_domain': 'acmeinc.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}])
Expand Down
17 changes: 10 additions & 7 deletions tests/middleware_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MoesifMiddlewareTest(TestCase):

def setUp(self):
self.request_factory = RequestFactory()
self.user = User.objects.create_user(username='testpythonapiuser', email='test@test.com', password='top_secret')
self.user = User.objects.create_user(username='my_user_id', email='test@test.com', password='top_secret')

def test_get_patched_middlesettings(self):
def get_response(req):
Expand All @@ -32,7 +32,8 @@ class UpdateUserTests(SimpleTestCase):
def testUpdateUser(self):
middleware = moesif_middleware(None)
middleware.update_user({
'user_id': 'testpythonapiuser',
'user_id': '12345',
'company_id' : '67890',
'session_token': 'jkj9324-23489y5324-ksndf8-d9syf8',
'metadata': {'email': 'abc@email.com', 'name': 'abcde', 'image': '1234'}
})
Expand All @@ -43,10 +44,12 @@ class UpdateUsersBatchTest(SimpleTestCase):
def testUpdateUsersBatch(self):
middleware = moesif_middleware(None)
middleware.update_users_batch([{
'user_id': 'testpythonapiuser',
'user_id': '12345',
'company_id' : '67890',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}, {
'user_id': 'testpythonapiuser1',
'user_id': '1234',
'company_id' : '6789',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}])

Expand All @@ -55,7 +58,7 @@ class UpdateCompanyTest(SimpleTestCase):
def testUpdateCompany(self):
middleware = moesif_middleware(None)
middleware.update_company({
'company_id': '1',
'company_id': '12345',
'company_domain': 'acmeinc.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcde', 'image': '1234'}
})
Expand All @@ -66,11 +69,11 @@ class UpdateCompaniesBatchTest(SimpleTestCase):
def testUpdateCompaniesBatch(self):
middleware = moesif_middleware(None)
middleware.update_companies_batch([{
'company_id': '1',
'company_id': '12345',
'company_domain': 'nowhere.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}, {
'company_id': '2',
'company_id': '67890',
'company_domain': 'acmeinc.com',
'metadata': {'email': 'abc@email.com', 'name': 'abcdefg', 'image': '123'}
}])
Expand Down

0 comments on commit 0642144

Please sign in to comment.