def test_can_register_a_user(self):
        response = self.client.post('/users', json=json.loads("""{
        "username" : "Alice",
        "password" : "alki324d",
        "about" : "I love playing the piano and travelling."
    }"""))

        json_response = json.loads(response.get_data(as_text=True))

        assert 201 == response.status_code
        assert "Alice" == json_response['username']
        assert "I love playing the piano and travelling." == json_response['about']
        assert validate_uuid4_string(json_response['id']) is True
예제 #2
0
    def test_can_create_a_new_post(self):
        register_response = self.client.post('/users',
                                             json=json.loads("""{
                "username" : "Alice",
                "password" : "alki324d",
                "about" : "I love playing the piano and travelling."
            }"""))

        registered_user = json.loads(register_response.get_data(as_text=True))
        response = self.client.post('/users/%s/timeline' %
                                    registered_user['id'],
                                    json=json.loads("""{
            "text" : "Hello everyone. I'm Alice."
        }"""))

        json_response = json.loads(response.get_data(as_text=True))

        assert 201 == response.status_code
        assert registered_user['id'] == json_response['userId']
        assert type(json_response['text']) is str
        assert type(json_response['dateTime']) is str
        assert validate_uuid4_string(json_response['postId'])
예제 #3
0
 def test_can_validate_a_valid_uuid4(self):
     assert validate_uuid4_string(uuid4().__str__()) is True
예제 #4
0
 def test_fails_to_validate_a_valid_hex_but_invalid_uuid4(self):
     assert validate_uuid4_string(
         '89eb35868a8247a4c911758a62601cf7') is False
예제 #5
0
 def test_fails_to_validate_an_invalid_uuid4(self):
     assert validate_uuid4_string('IamNotAUUID4') is False
예제 #6
0
 def test_can_validate_a_valid_uuid4_formatted_as_hex(self):
     assert validate_uuid4_string(
         '89eb35868a8247a4A911758a62601cf7') is True