Ejemplo n.º 1
0
    def test_create_note_valid(self):
        note = Note.create(email='*****@*****.**')
        self.assertEqual("<p>This is the text of my note.</p>", note.html)

        # check params
        note = Note.create(email='*****@*****.**', body="home")
        self.assertEqual("<p>This is the text of my note.</p>", note.html)
Ejemplo n.º 2
0
    def test_create_note_valid(self):
        note = Note.create(email='*****@*****.**')
        self.assertEqual("<p>This is the text of my note.</p>", note.html)

        # check params
        note = Note.create(email='*****@*****.**', body="home")
        self.assertEqual("<p>This is the text of my note.</p>", note.html)
Ejemplo n.º 3
0
 def test_find_note(self):
     # Find a note by id
     orig_note = Note.create(
         body="<p>Text for the note</p>",
         email=self.email)
     note = Note.find(id=orig_note.id)
     self.assertEqual(note.body, orig_note.body)
Ejemplo n.º 4
0
    def test_properties(self):
        note = Note()
        note.body = 'xxx'
        note.email = '*****@*****.**'
        note.user_id = '123'

        self.assertEqual('xxx', note.body)
        self.assertEqual('*****@*****.**', note.email)
        self.assertEqual('123', note.user_id)
Ejemplo n.º 5
0
    def test_properties(self):
        note = Note()
        note.body = 'xxx'
        note.email = '*****@*****.**'
        note.user_id = '123'

        self.assertEqual('xxx', note.body)
        self.assertEqual('*****@*****.**', note.email)
        self.assertEqual('123', note.user_id)
Ejemplo n.º 6
0
def test_note():
    httpretty.register_uri(
        post, r(r"/v1/users/notes"),
        body=fixture('v1-users-note'))
    note = Note.create(body="This is a note", email='*****@*****.**')
    eq_(note.html, "<p>This is a note</p>")
    eq_(note.user.email, "*****@*****.**")
Ejemplo n.º 7
0
def test_note():
    httpretty.register_uri(post,
                           r(r"/v1/users/notes"),
                           body=fixture('v1-users-note'))
    note = Note.create(body="This is a note", email='*****@*****.**')
    eq_(note.html, "<p>This is a note</p>")
    eq_(note.user.email, "*****@*****.**")
Ejemplo n.º 8
0
 def test_find_all_email(self):
     # Iterate over all notes for a user via their email address
     notes = Note.find_all(email=self.email)
     for note in notes:
         self.assertTrue(note.id is not None)
         user = note.user.load()
         self.assertEqual(user.email, self.email)
         break
Ejemplo n.º 9
0
 def test_find_all_email(self):
     # Iterate over all notes for a user via their email address
     notes = Note.find_all(email=self.email)
     for note in notes:
         self.assertTrue(note.id is not None)
         user = note.user.load()
         self.assertEqual(user.email, self.email)
         break
Ejemplo n.º 10
0
    def test_find_all_id(self):
        from intercom.user import User
        user = User.find(email=self.email)

        # Iterate over all notes for a user via their email address
        for note in Note.find_all(user_id=user.user_id):
            self.assertTrue(note.id is not None)
            user = note.user.load()
            self.assertEqual(user.email, self.email)
Ejemplo n.º 11
0
    def test_find_all_id(self):
        from intercom.user import User
        user = User.find(email=self.email)

        # Iterate over all notes for a user via their email address
        for note in Note.find_all(user_id=user.user_id):
            self.assertTrue(note.id is not None)
            user = note.user.load()
            self.assertEqual(user.email, self.email)
Ejemplo n.º 12
0
 def it_creates_a_note(self):
     data = {
         'body': '<p>Note to leave on user</p>',
         'created_at': 1234567890
     }
     with patch.object(Intercom, 'post', return_value=data) as mock_method:
         note = Note.create(body="Note to leave on user")
         mock_method.assert_called_once_with(
             '/notes/', body="Note to leave on user")  # noqa
         eq_(note.body, "<p>Note to leave on user</p>")
Ejemplo n.º 13
0
def test_properties():
    note = Note()
    note.body = 'xxx'
    note.email = '*****@*****.**'
    note.user_id = '123'
    note.created_at = datetime.fromtimestamp(1331764344)

    eq_(note.body, 'xxx')
    eq_(note.email, '*****@*****.**')
    eq_(note.user_id, '123')
Ejemplo n.º 14
0
    def it_sets_gets_allowed_keys(self):
        params = {
            'body': 'Note body',
            'email': '*****@*****.**',
            'user_id': 'abc123'
        }
        params_keys = list(params.keys())
        params_keys.sort()

        note = Note(**params)
        note_dict = note.to_dict
        note_keys = list(note_dict.keys())
        note_keys.sort()

        eq_(params_keys, note_keys)
        for key in params_keys:
            eq_(getattr(note, key), params[key])
Ejemplo n.º 15
0
 def test_create_note_identifiers(self):
     Note.create()
Ejemplo n.º 16
0
 def test_create_note_identifiers(self):
     Note.create()
Ejemplo n.º 17
0
 def test_save(self):
     note = Note(email='*****@*****.**')
     note.save()
     self.assertEqual(None, note.created_at)
     self.assertEqual('123', note.user.user_id)
     self.assertEqual("<p>This is the text of my note.</p>", note.html)
Ejemplo n.º 18
0
 def test_find_note(self):
     # Find a note by id
     orig_note = Note.create(body="<p>Text for the note</p>",
                             email=self.email)
     note = Note.find(id=orig_note.id)
     self.assertEqual(note.body, orig_note.body)
Ejemplo n.º 19
0
 def test_create_note(self):
     # Create a note for a user
     note = Note.create(body="<p>Text for the note</p>", email=self.email)
     self.assertIsNotNone(note.id)
Ejemplo n.º 20
0
 def test_save(self):
     note = Note(email='*****@*****.**')
     note.save()        
     self.assertEqual("<p>This is the text of my note.</p>", note.html)
Ejemplo n.º 21
0
 def test_create_note(self):
     # Create a note for a user
     note = Note.create(
         body="<p>Text for the note</p>",
         email=self.email)
     self.assertIsNotNone(note.id)
Ejemplo n.º 22
0
 def test_save(self):
     note = Note(email='*****@*****.**')
     note.save()
     self.assertEqual(None, note.created_at)
     self.assertEqual('123', note.user.user_id)
     self.assertEqual("<p>This is the text of my note.</p>", note.html)
Ejemplo n.º 23
0
 def it_creates_a_note(self):
     data = {"body": "<p>Note to leave on user</p>", "created_at": 1234567890}
     with patch.object(Intercom, "post", return_value=data) as mock_method:
         note = Note.create(body="Note to leave on user")
         mock_method.assert_called_once_with("/notes/", body="Note to leave on user")  # noqa
         eq_(note.body, "<p>Note to leave on user</p>")