Ejemplo n.º 1
0
    def test_get_all_my_mock(self):
        # arrange
        expected_genres = [
            GenreMother.one().build(),
            GenreMother.two().build()
        ]
        usecase = GenreUsecases(GenreDBRepoMock())

        # act
        result_genres = usecase.get_all_genres()

        # assert
        for i in range(len(expected_genres)):
            assert result_genres[i].name == expected_genres[i].name
Ejemplo n.º 2
0
    def test_all_mock(self, client, mocker):
        # arrange
        test_genres = [GenreMother.one().build(), GenreMother.two().build()]
        mocker.patch('modules.DBRepo.GenreDBRepo.GenreDBRepo.get_all',
                     return_value=test_genres)
        expected_resp = [
            genreToDict(test_genres[i]) for i in range(len(test_genres))
        ]
        view = GenresListView()

        # act
        resp = view.get(HttpRequest())

        # assert
        assert expected_resp == resp.data
Ejemplo n.º 3
0
    def test_get_success(self, mocker):
        # arrange
        expected_genres = [
            GenreMother.one().build(),
            GenreMother.two().build()
        ]
        mocker.patch('modules.DBRepo.GenreDBRepo.GenreDBRepo.get_all',
                     return_value=expected_genres)
        usecase = GenreUsecases(GenreDBRepo())

        # act
        result_genres = usecase.get_all_genres()

        # assert
        for i in range(len(expected_genres)):
            assert result_genres[i].name == expected_genres[i].name
Ejemplo n.º 4
0
    def test_get_one_my_mock(self):
        # arrange
        usecase = GenreUsecases(GenreDBRepoMock())
        test_id = 1
        expected_genre = GenreMother.one().build()

        # act
        result_genres = usecase.get_genre(test_id)

        # assert
        assert result_genres.name == expected_genre.name
Ejemplo n.º 5
0
    def test_get_one_success_london(self, mocker):
        # arrange
        usecase = GenreUsecases(GenreDBRepo())
        test_id = 1
        expected_genre = GenreMother.one().build()
        mocker.patch('modules.DBRepo.GenreDBRepo.GenreDBRepo.get',
                     return_value=expected_genre)

        # act
        result_genres = usecase.get_genre(test_id)

        # assert
        assert result_genres.name == expected_genre.name
Ejemplo n.º 6
0
    def test_get_mock(self, client, mocker):
        # arrange
        test_genre = GenreMother.one().build()
        test_id = 1
        mocker.patch('modules.DBRepo.GenreDBRepo.GenreDBRepo.get',
                     return_value=test_genre)
        view = GenreView()

        # act
        resp = view.get(HttpRequest(), test_id)

        # assert
        assert genreToDict(test_genre) == resp.data
Ejemplo n.º 7
0
 def get(genre_id) -> Genre:
     return GenreMother.one().build()
Ejemplo n.º 8
0
 def get_all() -> List[Genre]:
     return [GenreMother.one().build(), GenreMother.two().build()]