예제 #1
0
def test_delete_media():
    test_media1 = Game('test_name', 'test_path', 'test_genres', 'test_platform', 'test_mult', 'test-id')
    test_media2 = Game('test_name', 'test_path', 'test_genres', 'test_platform', 'test_mult', 'test-id2')
    test_user = user.User({'media': [test_media1.as_json(), test_media2.as_json()], '_id': ''})
    with patch.object(user, 'DB', {config.MONGODB_USER_COLLECTION_NAME: MagicMock()}):
        test_user.delete_media(test_media2.id_code)
    assert test_user.media == [test_media1.as_json()]
예제 #2
0
def test_read_media_error():
    test_media = Game('test_name', 'test_path', 'test_genres', 'test_platform', 'test_mult', 'test-id')
    test_user = user.User({'media': [test_media.as_json()], '_id': ''})
    with pytest.raises(ValueError):
        result = test_user.read_media('not an id code')
예제 #3
0
def test_read_media():
    test_media1 = Game('test_name', 'test_path', 'test_genres', 'test_platform', 'test_mult', 'test-id')
    test_media2 = Game('test_name', 'test_path', 'test_genres', 'test_platform', 'test_mult', 'test-id2')
    test_user = user.User({'media': [test_media1.as_json(), test_media2.as_json()], '_id': ''})
    result = test_user.read_media(test_media2.id_code)
    assert result == test_media2.as_json()
예제 #4
0
def test_create_media():
    test_media = Game('test_name', 'test_path', 'test_genres', 'test_platform', 'test_mult', 'test-id')
    test_user = user.User({'media': [], '_id': ''})
    with patch.object(user, 'DB', {config.MONGODB_USER_COLLECTION_NAME: MagicMock()}):
        test_user.create_media(test_media)
    assert test_user.media == [test_media.as_json()]
예제 #5
0
def test_media_prop():
    test_user = user.User({'media': ['media-item']})
    assert test_user.media == ['media-item']
예제 #6
0
def test_update_media_error():
    test_media = Game('test_name', 'test_path', 'test_genres', 'test_platform', 'test_mult', 'test-id')
    test_media2 = Game('test_name', 'test_path', 'test_genres', 'test_platform', 'test_mult', 'test-id2')
    test_user = user.User({'media': [test_media.as_json()], '_id': ''})
    with pytest.raises(ValueError):
        test_user.update_media(test_media2)