-
Notifications
You must be signed in to change notification settings - Fork 164
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
Write unit test for TaskView.get_title() #1083
Write unit test for TaskView.get_title() #1083
Conversation
f8017ed
to
f917b2c
Compare
dd7654a
to
a05a1a1
Compare
text = self.task.content | ||
title = self.task.title | ||
|
||
# Insert text and tags as a non_undoable action, otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code has moved to the TaskView class. The logic hasn't changed besides the way the objects are named (self.insert()
instead of self.textview.insert()
etc) and the fact that the TextView calls is_new()
on the task object.
def test_get_title(self): | ||
task_title = 'Very important task' | ||
task = Task(id = uuid4(), title=task_title) | ||
view = TaskView(Datastore(), task, None, False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 lines can probably be encapsulated into a create_task_view_from_task()
test helper, but I can do that when I add another test.
Ugh okay, let's not merge that yet... GHA fails with "Fatal Python error: Segmentation fault", which is going to be a joy to debug. |
OK so I have confirmed that this is caused by |
a05a1a1
to
328f6f1
Compare
de7cb07
to
5cb9d90
Compare
I think this is worth merging even though I haven't solved the segfault issue (it anyone wants to look: https://github.com/getting-things-gnome/gtg/actions/runs/8864137269/job/24339006474?pr=1083), and even though it looks like the bug I set out to fix will be fixed by #1102 I'll work on unskipping the test separately. |
I managed to reproduce the segfault outside of the GitHub Action using a small server VM. The main problem seems to be that GA runs without any graphical display features, and the new GUI test wants to use these features. If you provide a fake display server, everything works fine:
|
5cb9d90
to
807466c
Compare
Thanks a lot for looking into it! That would have taken me a while to figure out. It feels a bit like a hack somehow? But I can't really articulate why, nor do I have a better way to fix the problem =D |
I think we can defend the move:
|
I started to look at getting-things-gnome#1077 and I thought it would be nice to be able to unit test this type of thing. A simple unit test for TaskView would be * create a task * create a view for it * check that the title of the view is the title of the task In the current state of affairs, this is difficult because the code that puts the Task data into the view lives in TaskEditor. But we pass a Task to the constructor of TaskView, so TaskView actually has all the data it needs. So I moved the logic there. I also moved the `is_new()` logic from the TaskEditor down to the Task. I feel like it should be possible to eventually do this in the TaskView constructor but for now, TaskEditor calls `self.textview.set_text_from_task()` from the same place it used to run that code. The test triggers a segmentation fault when running on GitHub Actions, so it's skipped there while I figure out why.
807466c
to
3f833b4
Compare
Hi @SqAtx, this LGTM. Is this ready to merge or is there something else to do in this branch? |
@diegogangl It's ready to merge! It's a good first step. |
Thanks! |
I started to look at #1077 and I thought it would be nice to be able to unit test this type of thing.
A simple unit test for TaskView would be
In the current state of affairs, this is difficult because the code that puts the Task data into the view lives in TaskEditor. But we pass a Task to the constructor of TaskView, so TaskView actually has all the data it needs. So I moved the logic there. I also moved the
is_new()
logic from the TaskEditor down to the Task.I feel like it should be possible to eventually do this in the TaskView constructor but for now, TaskEditor calls
self.textview.set_text_from_task()
from the same place it used to run that code.The test triggers a segmentation fault when running on GitHub Actions, so it's skipped there while I figure out why.