Skip to content

Commit

Permalink
First tests done
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacy Janiszewski committed Aug 27, 2020
1 parent 79d8751 commit e9c6d01
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 8 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

## Example of usage:

` python src/run_from_file.py -m <movie_id> `
`python run_from_file.py -m <movie_id>`

i.e.

` python src/run_from_file.py -m 1 `
`python run_from_file.py -m 1`

or via Docker (just change the last line in Dockerfile)

`RUN python src/run_from_file.py -m 1 `

`RUN python run_from_file.py -m 1 `

### Python Version
` python -V `

$ Python 3.7.6
`python -V`

\$ Python 3.7.6
2 changes: 1 addition & 1 deletion src/run_from_file.py → run_from_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import argparse

from main import GetInfo
from src.main import GetInfo


class GetArgument:
Expand Down
Empty file added src/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
from typing import List

from settings import comments_data, movies_data
from src.settings import comments_data, movies_data


@dataclass
Expand Down
Empty file added tests/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions tests/test_concatenate_df.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pandas as pd

from src.settings import comments_data, movies_data
from src.main import IngestData



def test_comments_concatenate():
com_id = IngestData(**comments_data)
comments_df = com_id.get_df()
assert comments_df.shape[0] > 1000
assert comments_df.shape[1] == 4
45 changes: 45 additions & 0 deletions tests/test_get_info_from_df.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import pandas as pd

from src.main import GetInfo


def create_comments_example_df():
data = {
"id_comment": [no for no in range(6)],
"user": [f"user{user_no}" for user_no in range(6)],
"id_movie": [1 for no in range(3)] + [2 for no in range(3)]
}
df = pd.DataFrame(data, columns = data.keys()).set_index("id_comment")
return df


def create_movies_example_df():
data = {
"id_movie": [no for no in range(6)],
"title": [f"movie_{movie}" for movie in range(6)],
"ig_game": [1 for no in range(3)] + [2 for no in range(3)]
}
df = pd.DataFrame(data, columns = data.keys()).set_index("id_movie")
return df



def test_get_movie_comments():
example_df = create_comments_example_df()
gi = GetInfo()
comments_no = gi.get_movie_comments(1, example_df)
assert comments_no == 3


def test_get_movie_title():
example_df = create_movies_example_df()
gi = GetInfo()
movie_title = gi.get_movie_title(1, example_df)
assert movie_title == "movie_1"


def test_get_movie_title_no_movie_id():
example_df = create_movies_example_df()
gi = GetInfo()
movie_title = gi.get_movie_title('X', example_df)
assert movie_title == None

0 comments on commit e9c6d01

Please sign in to comment.