Closed yftzz closed 4 years ago
https://github.com/googleinterns/power-data-graphing-intern-2020/blob/5f74ac3a505289212e34065f63e7d4388880363d/frontend/src/app/app.component.spec.ts#L33-L37
In this test, I find the compiler warning that Property 'title' does not exist on type 'AppComponent'.ts(2339)
.
The original app.component.ts
looks like
https://github.com/googleinterns/power-data-graphing-intern-2020/blob/4bd6c1f3be752ef3167ddf318b1214a1d9d3e8b7/frontend/src/app/app.component.ts#L1-L26
which does not have a title
member as well.
I'm wondering if this a typo or am I missing something?
@Longzhao-Google
In this test, I find the compiler warning that
Property 'title' does not exist on type 'AppComponent'.ts(2339)
. The originalapp.component.ts
looks like https://github.com/googleinterns/power-data-graphing-intern-2020/blob/4bd6c1f3be752ef3167ddf318b1214a1d9d3e8b7/frontend/src/app/app.component.ts#L1-L26which does not have a
title
member as well. I'm wondering if this a typo or am I missing something? @Longzhao-Google
So in your test, you are creating the component by running "const app = fixture.componentInstance", just imagine it works the same as const app = new AppComponent(); Now you have the reference of the component, you are trying to get the title variable of the component by running "app.title", but in your AppComponent class, there is no variable named as 'title', which causes the error. Is this test auto generated by the compiler? if so, you can delete it or modify it to fit your current code.
Just found the python unit test framework - pytest is already included in python3. So you should be able to write python tests without any issues. I tried to add a python test locally - test_example.py and run it with "pytest" command which works. Following are the content of the test_example.py and the pytest output. Please feel free to add your python tests in the coming commits. Technically, each python method should have at least 1 test method. For example, create a main_test.py which includes all the tests for each method in main.py.
(venv) yaomeng@yaomeng:~/github/power-data-graphing-intern-2020/backend$ cat test_example.py `
class TestExampleClass:
def test_should_pass(self):
x = "this"
assert "h" in x
def test_should_fail(self):
x = "hello"
assert hasattr(x, "check")
`
`
$ pytest ========================= test session starts ========================= platform linux -- Python 3.7.7, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 rootdir: /usr/local/google/home/yaomeng/github/power-data-graphing-intern-2020/backend plugins: localserver-0.5.0, cov-2.10.0 collected 2 items
test_example.py .F [100%]
============================== FAILURES =============================== __ TestExampleClass.test_should_fail __
self = <test_example.TestExampleClass object at 0x7f99b7c35990> def test_should_fail(self): x = "hello" > assert hasattr(x, "check") E AssertionError: assert False E + where False = hasattr('hello', 'check') test_example.py:8: AssertionError ======================= short test summary info ======================= FAILED test_example.py::TestExampleClass::test_should_fail - Asserti... ===================== 1 failed, 1 passed in 0.07s =====================
`
Just added unit tests for backend functions, including downsample strategies and utils functions.