Пример #1
0
 def test_uses_service_to_create_a_new_user(self):
     user_attrs = {
         "name": "First",
         "surname": "Name",
         "email": "*****@*****.**",
         "partner_id": "WL_PARTNER",
         "preferences": {"locale": "en"},
     }
     user = User(**user_attrs)
     user.save()
     create_user_call = self.client.create_user.call_args[1]
     self.assertEqual(user_attrs, create_user_call)
Пример #2
0
 def test_uses_service_to_create_a_new_user(self):
     user_attrs = {
         'name': 'First',
         'surname': 'Name',
         'email': '*****@*****.**',
         'partner_id': 'WL_PARTNER',
         'preferences': {
             'locale': 'en'
         },
     }
     User.create(**user_attrs)
     create_user_call = self.client.create_user.call_args[1]
     self.assertEqual(user_attrs, create_user_call)
Пример #3
0
    def test_instantiates_user_with_attrs_from_service(self):
        self.client.get_user.return_value = {
            "id": "123",
            "name": "Firstname",
            "surname": "Lastname",
            "email": "*****@*****.**",
            "active": True,
            "signupDate": "2016-01-01",
            "deleted": "2016-02-01",
            "partner_id": "PARTNER",
            "preferences": {"currency": "USD"},
        }

        user = User.get("123")

        self.client.get_user.assert_called_once_with("123")
        self.assertEqual(user.id, "123")
        self.assertEqual(user.active, True)
        self.assertEqual(user.deleted, "2016-02-01")
        self.assertEqual(user.signup_date, "2016-01-01")
        self.assertEqual(user.partner_id, "PARTNER")
        self.assertEqual(user.name, "Firstname")
        self.assertEqual(user.surname, "Lastname")
        self.assertEqual(user.email, "*****@*****.**")
        self.assertEqual(user.name, "Firstname")
        self.assertDictEqual(user.preferences, {"currency": "USD"})
Пример #4
0
    def setUp(self):
        super(TestUserGet, self).setUp()
        self.client.get_user.return_value = {
            'id': '123',
            'name': 'Firstname',
            'surname': 'Lastname',
            'email': '*****@*****.**',
            'active': True,
            'signup_date': '2016-01-01',
            'deleted': '2016-02-01',
            'partner_id': 'PARTNER',
            'preferences': {
                'currency': 'USD'
            },
            'preferred_greeting': 'hi',
        }

        self.user = User.get('123')
Пример #5
0
 def test_updates_all_attributes_passed_in(self):
     user_attrs = {'name': 'Nameski', 'email': '*****@*****.**'}
     u = User()
     u.update(**user_attrs)
     self.assertEqual(u.name, 'Nameski')
     self.assertEqual(u.email, '*****@*****.**')
Пример #6
0
 def test_can_be_set_via_attribute(self):
     user = User()
     user.partner_id = 'WL_CAT'
     self.assertEqual(user.partner_id, 'WL_CAT')
Пример #7
0
 def test_can_be_set_via_init(self):
     self.assertEqual(User(partner_id='WL_DOG').partner_id, 'WL_DOG')
Пример #8
0
 def test_uses_client_config_as_default_partner_id(self):
     self.assertEqual(User().partner_id, 'WL_DEFAULT')
Пример #9
0
 def test_is_a_yola_client(self):
     self.assertEqual(User().get_client(), self.client)
Пример #10
0
 def test_updates_all_attributes_passed_in(self):
     user_attrs = {"name": "Nameski", "email": "*****@*****.**"}
     u = User()
     u.update(**user_attrs)
     self.assertEqual(u.name, "Nameski")
     self.assertEqual(u.email, "*****@*****.**")
Пример #11
0
 def test_can_be_set_via_attribute(self):
     user = User()
     user.partner_id = "WL_CAT"
     self.assertEqual(user.partner_id, "WL_CAT")