Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking database examples on the guide #2873

Merged
merged 11 commits into from Jan 10, 2019

Conversation

Projects
None yet
4 participants
@dpshelio
Copy link
Member

commented Dec 16, 2018

This should be able to generate the documentation without breaking the tests. Completely offline! if we want to check that the results still apply, then we can remove the two testsetup sections and it should work. How to do that in an automated way... I don't know.

Fixes #2871 - I think...

Also improved the way database looks into a directory by sorting the files within it, so we get always the same result.

@sunpy-bot

This comment has been minimized.

Copy link

commented Dec 16, 2018

Thanks for the pull request @dpshelio! Everything looks great!

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2018

If this works. You are a beautiful human being.

@nabobalis nabobalis added this to the 1.0 milestone Dec 16, 2018

@dpshelio

This comment has been minimized.

Copy link
Member Author

commented Dec 16, 2018

Why I don't get giles in here???

@dpshelio

This comment has been minimized.

Copy link
Member Author

commented Dec 16, 2018

Ok, maybe because the last commit said [ci skip]. I think this is the built documentation.

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented Dec 16, 2018

2018-12-16T20:29:25.1945060Z _________________________________________________________________ [doctest] docs/guide/acquiring_data/database.rst _________________________________________________________________
2018-12-16T20:29:25.1945480Z 251 .. testsetup:: *
2018-12-16T20:29:25.1945790Z 252    >>> from unittest.mock import Mock
2018-12-16T20:29:25.1946140Z 253    >>> from sunpy.tests.mocks import MockObject
2018-12-16T20:29:25.1946660Z 254    >>> class MockQR:
2018-12-16T20:29:25.1946950Z 255    ...    def __init__(self, start_time, instrument, wavelength):
2018-12-16T20:29:25.1948510Z 256    ...        end_time = '{}{}'.format(start_time[:-1], int(start_time[-1]) + 1)
2018-12-16T20:29:25.1948650Z 257    ...        self.time = MockObject(start=start_time, end=end_time)
2018-12-16T20:29:25.1948700Z 258    ...        self.instrument = instrument
2018-12-16T20:29:25.1949790Z 259    ...        self.wave = MockObject(wavemin=wavelength, wavemax=wavelength, waveunit='nm')
2018-12-16T20:29:25.1949920Z 260    >>> client.search = Mock(return_value=[MockQR(f"2011050800000{t}",
2018-12-16T20:29:25.1952980Z UNEXPECTED EXCEPTION: NameError("name 'client' is not defined")
2018-12-16T20:29:25.1954020Z Traceback (most recent call last):
2018-12-16T20:29:25.1954110Z 
2018-12-16T20:29:25.1954880Z   File "/Users/vsts/agent/2.144.0/work/1/s/.tox/py37-offline/lib/python3.7/doctest.py", line 1329, in __run
2018-12-16T20:29:25.1955020Z     compileflags, 1), test.globs)
2018-12-16T20:29:25.1955050Z 
2018-12-16T20:29:25.1955140Z   File "<doctest database.rst[23]>", line 3, in <module>
2018-12-16T20:29:25.1955190Z 
2018-12-16T20:29:25.1955680Z NameError: name 'client' is not defined
2018-12-16T20:29:25.1955730Z 
2018-12-16T20:29:25.1955780Z /Users/vsts/agent/2.144.0/work/1/s/docs/guide/acquiring_data/database.rst:260: UnexpectedException2018-12-16T20:29:25.1945060Z _________________________________________________________________ [doctest] docs/guide/acquiring_data/database.rst _________________________________________________________________
2018-12-16T20:29:25.1945480Z 251 .. testsetup:: *
2018-12-16T20:29:25.1945790Z 252    >>> from unittest.mock import Mock
2018-12-16T20:29:25.1946140Z 253    >>> from sunpy.tests.mocks import MockObject
2018-12-16T20:29:25.1946660Z 254    >>> class MockQR:
2018-12-16T20:29:25.1946950Z 255    ...    def __init__(self, start_time, instrument, wavelength):
2018-12-16T20:29:25.1948510Z 256    ...        end_time = '{}{}'.format(start_time[:-1], int(start_time[-1]) + 1)
2018-12-16T20:29:25.1948650Z 257    ...        self.time = MockObject(start=start_time, end=end_time)
2018-12-16T20:29:25.1948700Z 258    ...        self.instrument = instrument
2018-12-16T20:29:25.1949790Z 259    ...        self.wave = MockObject(wavemin=wavelength, wavemax=wavelength, waveunit='nm')
2018-12-16T20:29:25.1949920Z 260    >>> client.search = Mock(return_value=[MockQR(f"2011050800000{t}",
2018-12-16T20:29:25.1952980Z UNEXPECTED EXCEPTION: NameError("name 'client' is not defined")
2018-12-16T20:29:25.1954020Z Traceback (most recent call last):
2018-12-16T20:29:25.1954110Z 
2018-12-16T20:29:25.1954880Z   File "/Users/vsts/agent/2.144.0/work/1/s/.tox/py37-offline/lib/python3.7/doctest.py", line 1329, in __run
2018-12-16T20:29:25.1955020Z     compileflags, 1), test.globs)
2018-12-16T20:29:25.1955050Z 
2018-12-16T20:29:25.1955140Z   File "<doctest database.rst[23]>", line 3, in <module>
2018-12-16T20:29:25.1955190Z 
2018-12-16T20:29:25.1955680Z NameError: name 'client' is not defined
2018-12-16T20:29:25.1955730Z 
2018-12-16T20:29:25.1955780Z /Users/vsts/agent/2.144.0/work/1/s/docs/guide/acquiring_data/database.rst:260: UnexpectedException
@Cadair

This comment has been minimized.

Copy link
Member

commented Dec 16, 2018

if this is now all offline we can and should go through and remove all the REMOTE_DATA directives.

@Cadair

This comment has been minimized.

Copy link
Member

commented Dec 16, 2018

that implies the testsetup blocks are not in the same namespace as the rest of the inline code?! 😕

@dpshelio

This comment has been minimized.

Copy link
Member Author

commented Dec 17, 2018

testsetup blocks are supposed to be in the same namespace. That's the idea of the testsetup, at least with a * on them. I don't really know why that doctest here. Ideally (and I don't know how we could do this) we could name these testsetups so that we could omit them if we want to actually update the outputs as using the online data.

@Cadair

This comment has been minimized.

Copy link
Member

commented Dec 17, 2018

maybe they are always run first? Either way I think you just need to patch VSOClient.search directly rather than doing it on the client variable.

@nabobalis nabobalis force-pushed the dpshelio:mock_doctest_database branch from fd077ea to 0cc7b6c Dec 18, 2018

@nabobalis nabobalis force-pushed the dpshelio:mock_doctest_database branch from 0cc7b6c to cb97e12 Jan 7, 2019

@pep8speaks

This comment has been minimized.

Copy link

commented Jan 7, 2019

Hello @dpshelio! Thanks for updating the PR.

Line 28:13: E128 continuation line under-indented for visual indent
Line 34:13: E128 continuation line under-indented for visual indent
Line 35:13: E128 continuation line under-indented for visual indent
Line 36:13: E128 continuation line under-indented for visual indent
Line 647:101: E501 line too long (103 > 100 characters)

Comment last updated on January 10, 2019 at 15:22 Hours UTC
@nabobalis

This comment has been minimized.

Copy link
Contributor

commented Jan 7, 2019

My fix was not a fix. Back to the drawing board.

@nabobalis nabobalis force-pushed the dpshelio:mock_doctest_database branch from cb97e12 to 1df4567 Jan 7, 2019

@nabobalis nabobalis force-pushed the dpshelio:mock_doctest_database branch 3 times, most recently from 1cc2873 to 1c7b56f Jan 7, 2019

@@ -60,7 +60,6 @@ jobs:

- checkout
- run: *skip-check
- run: *merge-check

This comment has been minimized.

Copy link
@nabobalis

nabobalis Jan 7, 2019

Contributor

Running ssh on such an old system is a bad idea for my health.

@nabobalis
Copy link
Contributor

left a comment

Lets just merge this and deal with the rest later.

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented Jan 7, 2019

App fail is fixed in another PR.
The 32bit one is also fixed in another PR.

The rest should pass!

@Cadair

This comment has been minimized.

Copy link
Member

commented Jan 8, 2019

I would like to see at least one test build pass 😛 Looks like we have issues with the latest pytest again.

@nabobalis nabobalis force-pushed the dpshelio:mock_doctest_database branch from 1f9fd90 to 3cf7972 Jan 9, 2019

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2019

Rebased it on a working CI. Let us see what happens!

@nabobalis nabobalis force-pushed the dpshelio:mock_doctest_database branch from 3cf7972 to 3c72742 Jan 10, 2019

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented Jan 10, 2019

I restarted the build but it seems to have been fixed now.

@Cadair

Cadair approved these changes Jan 10, 2019

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented Jan 10, 2019

ALL GREEN

@nabobalis nabobalis merged commit f0467ad into sunpy:master Jan 10, 2019

12 checks passed

ci/circleci: 32bit Your tests passed on CircleCI!
Details
ci/circleci: egg-info-36 Your tests passed on CircleCI!
Details
ci/circleci: egg-info-37 Your tests passed on CircleCI!
Details
ci/circleci: figure-tests-36 Your tests passed on CircleCI!
Details
ci/circleci: html-docs Your tests passed on CircleCI!
Details
ci/circleci: pip Your tests passed on CircleCI!
Details
codecov/patch Coverage not affected when comparing 3c72742...5f5287f
Details
codecov/project 86.45% (+<.01%) compared to 3c72742
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
giles Click details to preview the documentation build
Details
sunpy-bot All checks passed
sunpy.sunpy Build #20190110.12 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.